﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FineUI;
using Maticsoft.BLL;
using Maticsoft.Model;

namespace FineUI.Examples
{
    public partial class admin_addclass : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            if (Session["UserName"] == null)
            {
                Response.Redirect("~/login.aspx");
            }
        }

        protected void btnAddClass_Click(object sender, EventArgs e)
        {

            if (tbxClassName.Text == "")
            {
                Alert.ShowInTop("请输入教室的名称!");
                return;
            }

            string currentClassName = tbxClassName.Text.ToString();
            Maticsoft.BLL.Class Class = new Maticsoft.BLL.Class();
            Maticsoft.Model.Class ClassInfom = new Maticsoft.Model.Class();
            if (!Class.Exists(currentClassName))
            {
                ClassInfom.CL_Id = currentClassName;
                ClassInfom.CL_Name = currentClassName;
                ClassInfom.CL_Address = dropDownListClass.SelectedValue.ToString();
                Class.Add(ClassInfom);
                Alert.ShowInTop("新增教室成功!");

            }
            else 
            {
                Alert.ShowInTop("该教室已经存在");
                return;
            }

        }
    }
}